from .base import Space
import random

class MySpace(Space):
    def sample(self, seed=0):
        random.seed(seed)
        return random.randint(0, 9)

    def contains(self, x):
        return isinstance(x, int) and 0 <= x <= 9

    def flatten(self, x):
        return [x]

    def unflatten(self, x):
        return x[0]

    def flatten_n(self, xs):
        return xs

    def unflatten_n(self, xs):
        return xs

    @property
    def flat_dim(self):
        return 1  # 维度为1，因为扁平化后得到一维数组

